package com.hliushi.drools.service;

import com.hliushi.drools.entity.Student;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author llhuang10
 * @date 2021/10/12 9:56
 */
@Service
public class RuleService {

    @Resource
    private KieBase kieBase;

    /**
     *
     */
    public void rule() {
        KieSession kieSession = kieBase.newKieSession();
        Student student = new Student();
        student.setAge(25);
        kieSession.insert(student);
        kieSession.fireAllRules();
        kieSession.dispose();
    }
}
